package com.jzo2o.customer.controller.agency;


import com.jzo2o.api.customer.dto.request.InstitutionStaffPageQueryReqDTO;
import com.jzo2o.api.customer.dto.response.InstitutionStaffResDTO;
import com.jzo2o.common.model.CurrentUserInfo;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.common.utils.BeanUtils;
import com.jzo2o.customer.model.domain.BankAccount;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.request.InstitutionStaffUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.model.dto.response.InstitutionStaffSimpleResDTO;
import com.jzo2o.customer.service.BankAccountService;
import com.jzo2o.customer.service.IInstitutionStaffService;
import com.jzo2o.mvc.utils.UserContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 机构下属服务人员 前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-07-18
 */
@RestController("agencyBankAccountController")
@RequestMapping("/agency/bank-account")
@Api(tags = "机构端 - 新增或更新银行账号信息接口")
public class BankAccountController {
    @Resource
    private BankAccountService bankAccountService;
    @PostMapping
    @ApiOperation("新增机构下属服务人员")
    public void add(@RequestBody BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
        //没有想到怎么确定是服务人员还是服务机构
        CurrentUserInfo currentUserInfo = UserContext.currentUser();
        bankAccountUpsertReqDTO.setId(currentUserInfo.getId());
        bankAccountUpsertReqDTO.setType(currentUserInfo.getUserType());
        bankAccountService.updateBankAccountInfo(bankAccountUpsertReqDTO);
    }

    @GetMapping("/currentUserBankAccount ")
    @ApiOperation("获取当前用户银行账号")
    public BankAccountResDTO getBankAccount() {
//        注意BankAccount里面的id就是当前用户的id
        CurrentUserInfo currentUserInfo = UserContext.currentUser();

        BankAccount bankAccount = bankAccountService.getBankAccount(currentUserInfo.getId());
        return BeanUtils.toBean(bankAccount, BankAccountResDTO.class);
    }
}
